﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using GalaSoft.MvvmLight;
using ZFSDomain.Interface.Base;

namespace ZFSDomain.ViewDialog.Group
{

    /// <summary>
    /// 用户组
    /// </summary>
    public class GroupView : IModel
    {

        private ZFSDomain.View.Group.GroupView view;

        private ZFSDomain.ViewModel.Group.GroupViewModel viewModel;

        /// <summary>
        /// 绑定默认数据上下文
        /// </summary>
        /// <param name="authValue"></param>
        public void BindDefaultViewModel(int? authValue)
        {
            if (viewModel == null)
            {
                viewModel = new ViewModel.Group.GroupViewModel();
                viewModel.AuthValue = authValue;
                viewModel.InitViewModel();
            }
            this.GetView().DataContext = viewModel;
        }

        /// <summary>
        /// 绑定指定上下文
        /// </summary>
        /// <typeparam name="TViewModel"></typeparam>
        /// <param name="viewModel"></param>
        public void BindViewModel<TViewModel>(TViewModel viewModel) where TViewModel : ViewModelBase
        {
            this.GetView().DataContext = viewModel;
        }

        /// <summary>
        /// 获取页
        /// </summary>
        /// <returns></returns>
        public UserControl GetView()
        {
            if (view == null)
            {
                view = new ZFSDomain.View.Group.GroupView();
            }
            return view;
        }
    }
}
